package com.woniu.zsd.recycle.consumer;

import com.woniu.zsd.common.util.RedisKey;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class DeleteCacheConsumer {
    @Resource
    private RedisTemplate<String,Object> redisObjectTemplate;
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue(name = "delete_cache_queue"),
                    exchange = @Exchange(name = "d3",type = "direct"),
                    key = "delete_cache"
            )
    })
    @RabbitHandler
    public void delKey(String key)throws Exception{
        redisObjectTemplate.delete(RedisKey.CACHE_TYPE_TREE());
    }
}
